package com.chencl.cipher.dao;

import com.chencl.cipher.entity.SecretKeyEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @program: rsa-aes-cipher-spring-boot
 * @description:
 * @author: jiangshengli
 * @create: 2022-03-18 09:14
 */
@Repository
@Mapper
public interface SecretKeyMapper {

    @Insert("insert into secret_key(appid,appname,private_key,public_key) values(#{appid},#{appname},#{privateKey},#{publicKey})")
    int insert(SecretKeyEntity secretKey);

    @Select("select max(appid)+1 from secret_key")
    int initAppid();

    @Select("select id,appid,appname,private_key privateKey,public_key publicKey from secret_key where appid=#{appid}")
    SecretKeyEntity querySecretKeyByAppid(String appid);
}
